package org.jxht.web.api;

import org.jxht.dto.FriendDto;
import org.jxht.dto.StudentDto;
import org.jxht.service.FriendService;
import org.jxht.service.StudentService;
import org.jxht.util.GsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by huang on 2016/11/21 0021.
 */
@Controller
@RequestMapping("JxhtWeb/FriendController")
public class FriendController {

    @Autowired
    private FriendService friendService;

    @RequestMapping(value = "{requestId}/addFriend",method = RequestMethod.POST)
    public void addFriend(@PathVariable int requestId,@RequestParam int friendId){
        FriendDto dto = new FriendDto(requestId,friendId);
        friendService.insertFriend(dto);
    }

    @RequestMapping(value = "{requestId}/quesyFriend")
    @ResponseBody
    public List<FriendDto> quesyFriend(@PathVariable int requestId){
        FriendDto dto = new FriendDto();
        dto.setuserId(requestId);
        return friendService.queryFriend(dto);
    }

    @RequestMapping(value = "{requestId}/deleteFriend",method = RequestMethod.POST)
    public void deleteFriend(@PathVariable int requestId,@RequestParam int friendId){
        FriendDto dto = new FriendDto(requestId,friendId);
        friendService.deleteFriendDao(dto);
    }
}
